<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>订单查询</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script language="javascript" type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">

$(function(){
	m1('m1_006');
});

/**************  查询  begin *******************/
function search(){
	var actionUrl = "${ctx}/order/list.do";

	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();

	if(startDate > endDate){
		alert("开始时间不能大于结束时间");
		return false;
	}
	
	$("#curPage").val(1);
	$("#searchForm").attr("action",actionUrl);
	$("#searchForm").submit();
}
/**************  查询  end *******************/

function searchBySequenceNo(){
	var actionUrl = "${ctx}/order/findBySequenceNo.do";
	
	$("#curPage").val(1);
	$("#searchForm").attr("action",actionUrl);
	$("#searchForm").submit();
}

function showDetail(id){

	art.dialog({
	    content: document.getElementById("order_detail_div"),
	    title:'订单详情'
    });
    
	$.ajax( {
		type : "GET",
		url : "${ctx}/order/detail.do?orderItmeId="+id+"&"+new Date().getTime(),
		timeout : 6000,
		async : true, //ajax同步
		success : function(data, textStatus) {
			var items = eval("("+data+")");
			$("#order_name").html(items.name);
			$("#order_sequenceNo").html(items.sequenceNo);
			$("#order_price").html(items.price);
			$("#order_num").html(items.num);
			$("#order_ship_name").html(items.ship_name);
			$("#order_ordertime").html(items.orderTime);
			if( items.payment_type == "online"){
				$("#order_paymenttype").html("网上支付");
			}else{
				$("#order_paymenttype").html("线下支付");
			}
			if(items.fpFlag == '1'){
				var fpType = items.fpType;
				if(items.fpType2 == '个人'){
					$("#order_fp").html(fpType+"&nbsp;&nbsp;&nbsp;&nbsp;个人");
				}
				else if(items.fpType2 == '单位'){
					$("#order_fp").html(fpType+"&nbsp;&nbsp;&nbsp;&nbsp;"+items.fpHead+"(公司)");
				}else{
					$("#order_fp").html(fpType);
				}
			}else{
				$("#order_fp").html("不开具发票");
			}
			$("#order_ship_mobile").html(items.ship_mobile);
			$("#order_shipaddress").html(items.ship_addr);
			$("#order_status").html(items.orderStatus);
		}
	});
}
</script>

</head>
<body>

<!-- 页面头部  -->
<jsp:include page="/commons/head_member.jsp"></jsp:include>

<form action="${ctx}/order/list.do" id="searchForm" name="searchForm" method="post">
	<table width="960" cellpadding="0" cellspacing="0" class="tbl_list_border" align="center">
		<tr><td>
				<table width="900" border="0" cellspacing="0" cellpadding="0" align="center"  style="margin: 0 auto;">
					<tr><td>
						<table width="100%" cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td class="nw12a" width="60" align="right">订单编号：</td>
								<td><input name="sequenceNo" type="text" size="15" value="${sequenceNo }"/>
								<img src="../images/an25.gif" width="50" height="21" onclick="return searchBySequenceNo()" style="cursor: pointer;vertical-align: middle;"/>
								</td>
							</tr>
							<tr>
							<td class="nw12a"  align="right">
								开始时间：</td><td style="font-family: 宋体;font-size: 12px;"> <input name="startDate" id="startDate" type="text" size="15" onclick="WdatePicker()" value="<fmt:formatDate value='${startDate }' pattern='yyyy-MM-dd'/>"/>&nbsp;&nbsp;
				              	结束时间：<input name="endDate" id="endDate" type="text" size="15" onclick="WdatePicker()"  value="<fmt:formatDate value='${endDate }' pattern='yyyy-MM-dd'/>" />&nbsp;&nbsp;
									<img src="../images/an25.gif" width="50" height="21" onclick="return search()" style="cursor: pointer;vertical-align: middle;"/>
								</td>
							</tr>
							<tr><td height="5"></td></tr>
						</table>
					</td></tr>
					<tr><td colspan="100%" valign="top">
						<table width="900" cellpadding="0" cellspacing="0" align="center" class="tbl">
			                  <tr bgcolor="#CDE1ED">
			                    <td height="35">订单号</td>
			                    <td>商品名称</td>
			                    <td>金额(元)</td>
			                    <td>数量</td>
			                    <td>下单人</td>
			                    <td>手机号</td>
			                    <td>下单时间</td>
			                    <td>订单状态</td>
			                  </tr>
			                   <c:forEach items="${page.result}" var="result" varStatus="status">
				                  <tr>
				                    <td height="40"><a href="javascript:showDetail(${result.id })">${result.order.sequenceNo }</a></td>
				                    <td>${result.name }</td>
				                    <td>${result.order.order_amount }</td>
				                    <td>${result.num }</td>
				                    <td>${result.order.customerInfo.userName }</td>
				                    <td>${result.order.ship_mobile }</td>
				                    <td><fmt:formatDate value="${result.order.orderTime }" pattern="yyyy-MM-dd HH:mm"/></td>
				                    <td>${result.order.orderStatus }</td>
				                  </tr>
			                  </c:forEach>
			              </table>
					</td></tr>
					<tr>
		              <td colspan="100%" class="nw12a" align="right" height="30">
		              		<jsp:include page="/commons/paging_footer.jsp"/>
		              </td>
		            </tr>
				</table>
		</td></tr>
	</table>
</form>   

<div id="order_detail_div" style="display: none;">
	<table width="700" cellpadding="0" cellspacing="0" align="center" class="tbl" style="margin-top: 10px">
           <tr><td height="35" width="20%">货品</td><td id="order_name"></td></tr>
           <tr><td height="35">订单号</td><td id="order_sequenceNo"></td></tr>
           <tr><td height="35">单价(元)</td><td id="order_price"></td></tr>
           <tr><td height="35">数量</td><td id="order_num"></td></tr>
           <tr><td height="35">收货人</td><td id="order_ship_name"></td></tr>
           <tr><td height="35">下单时间</td><td id="order_ordertime"></td></tr>
           <tr><td height="35">付款方式</td><td id="order_paymenttype"></td></tr>
           <tr><td height="35">联系方式</td><td id="order_ship_mobile"></td></tr>
           <tr><td height="35">收货地址</td><td id="order_shipaddress"></td></tr>
           <tr><td height="35">发票信息</td><td id="order_fp"></td></tr>
           <tr><td height="35">状态</td><td id="order_status"></td></tr>
	 </table>
</div>

<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>